package com.shlg.chuang.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.shlg.chuang.domain.Content;
import com.shlg.chuang.domain.ContextType;
import com.shlg.chuang.repository.ContentRepository;
import com.shlg.chuang.service.ContentService;

@Service
public class ContentServiceImpl implements ContentService{
	
	@Autowired
	private ContentRepository contentRepo;

	@Override
	public Content saveContent(Content content) {
		return contentRepo.save(content);
	}

	@Override
	public void deleteContent(Long contentId) {
		contentRepo.delete(contentId);
		
	}

	@Override
	public List<Content> searchContentWhereLocationLimitInScope(Double localLatitude, 
			Double localLongitude, Double scope) {
		return contentRepo
				.searchLatitudeSquAndLongitudeSquLessThanScope(localLatitude,
						localLongitude, scope);
	}

	@Override
	public List<Content> findContentByUserId(Long showUserId) {
		return contentRepo.findByShowUserId(showUserId);
	}

	@Override
	public Content findOne(Long contentId) {
		return contentRepo.findOne(contentId);
	}

	@Override
	public List<Content> filterByContentType(ContextType contextType, Double localLatitude, Double localLongitude, Double scope) {
		return contentRepo.filterByContentType(contextType, localLatitude, localLongitude, scope);
	}
	


}
